function img_slices(fbase, imgbase, fnum)
%
%   img_slices(fbase, imgbase, fnum)
%
%   Reads file with total density distribution.
%   Creates bunch of images.
%
%   Input:
%        fbase   base of file number (runname)
%        fnum    file number
%
%   Domain information and colormap limits are edited in the file.


%---------------------------------------------------------

% system size

jx=48; jy=48; jz=16; jv=64; jdir=6;


% colormap bounds for density :  0.02
% colormap bounds for Ez      :  0.05 (0.002)
% colormap bounds for Ex, Ey  :  0.004

fmax = 0.004, fmin = -fmax;


%-- reading data cube ------------------------------------

  fn = num2str(fnum,'%04d');

fname = [fbase, '.', fn];

  fid = fopen(fname, 'rb');
  f = fread(fid, jx*jy*jz, 'double');
  fclose(fid);

  f = reshape(f, jz,jy,jx);

  printf("limits :   [%8.4f, %8.4f]\n",  ...
	 min(min(min(f(:,:,:)))), max(max(max(f(:,:)))) )


%-- plotting slices ---------------------------------------



  ix = jx/2+1;

  f_slice = f(:, :, ix);
  f_slice = reshape(f_slice, jz, jy);

  figure (1, "Name", "x=0")
  imagesc(flipud(f_slice));

  fname = [imgbase, '.x0.', fn, '.png'];
  one_image(flipud(f_slice), fmin, fmax, fname);



  iy = jy/2+1;

  f_slice = f(:, iy, :);
  f_slice = reshape(f_slice, jz, jx);

  figure (2, "Name", "y=0")
  imagesc(flipud(f_slice));

  fname = [imgbase, '.y0.', fn, '.png'];
  one_image(flipud(f_slice), fmin, fmax, fname)



  iz = 1;

  f_slice = f(iz, :, :);
  f_slice = reshape(f_slice, jx, jy);

  figure (3, "Name", "z=0")
  imagesc(flipud(f_slice));

  fname = [imgbase, '.z0.', fn, '.png'];
  one_image(flipud(f_slice), fmin, fmax, fname)


  iz = jz/4+1;

  f_slice = f(iz, :, :);
  f_slice = reshape(f_slice, jx, jy);

  figure (4, "Name", "z=1/4")
  imagesc(flipud(f_slice));

  fname = [imgbase, '.z1.', fn, '.png'];
  one_image(flipud(f_slice), fmin, fmax, fname)


  iz = jz/2+1;

  f_slice = f(iz, :, :);
  f_slice = reshape(f_slice, jx, jy);

  figure (5, "Name", "z=2/4")
  imagesc(flipud(f_slice));

  fname = [imgbase, '.z2.', fn, '.png'];
  one_image(flipud(f_slice), fmin, fmax, fname)


  iz = 3*jz/4+1;

  f_slice = f(iz, :, :);
  f_slice = reshape(f_slice, jx, jy);

  figure (6, "Name", "Density, z=3/4")
  imagesc(flipud(f_slice));

  fname = [imgbase, '.z3.', fn, '.png'];
  one_image(flipud(f_slice), fmin, fmax, fname)


%---------------------------------------------------------
